//
//  HBInvestManager.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/17.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBInvestManager.h"
#import "HBGetUserInvestLimitParam.h"
#import "HBGetUserInvestLimitParser.h"

@implementation HBInvestManager

static HBInvestManager *sharedHBInvestManager = nil;

+ (HBInvestManager *)sharedHBInvestManager
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedHBInvestManager = [[HBInvestManager alloc]init];

    });
    return sharedHBInvestManager;
}

+ (void)requestToGetUserInvestLimitWithResult:(void (^)(BOOL, NSString *, NSError *))result
{
    HBGetUserInvestLimitParam *param = [[HBGetUserInvestLimitParam alloc]init];
    param.uid = [HBLoginManager sharedHBLoginManager].currentUserInfo.uid;
    param.token = [HBLoginManager sharedHBLoginManager].currentUserInfo.token;
    HBGetUserInvestLimitParser *parser = [[HBGetUserInvestLimitParser alloc]init];
    [NetCenter getDataFromURL:Method_getUserInvestLimit
                       params:param
                       parser:parser
                       result:^(ParserResult *myResult)
     {
         if (myResult.code ==0 )
         {
             HBGetUserInvestLimitInfo *info = (HBGetUserInvestLimitInfo *)myResult.result;
             
             [self sharedHBInvestManager].userInvestLimitInfo = info;
             if (result)
             {
                 result(YES, myResult.message, nil);
             }
         }
         else
         {
             if (result)
             {
                 result(NO, myResult.message, nil);
             }
         }
         
     } failure:^(NSError *error)
     {
         if (result)
         {
             result(NO, @"", error);
         }
     }];
}

@end
